﻿using Compose;
using RabbitMQ.Client;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ClassLibrary1
{
    //[CommandLine.Command(CommandName = "rabbit")]
    //public  class Rabbit: ICommand
    //{
    //    public void Dispose()
    //    {
    //        throw new NotImplementedException();
    //    }
    //    ConnectionFactory _connectionFactory = null;
    //    IConnection connection = null;
    //    public string Execute(string input)
    //    {
    //        try
    //        {               
    //            _connectionFactory = new ConnectionFactory();
    //            _connectionFactory.HostName = "mb.zhnyiot.com";
    //            _connectionFactory.UserName = "root";
    //            _connectionFactory.Password = "root";
    //            _connectionFactory.AutomaticRecoveryEnabled = true;
    //            connection = _connectionFactory.CreateConnection();
    //            IModel channel = connection.CreateModel();
    //            //创建队列，队列持久化
    //            channel.QueueDeclare("haha", false, false, true, null );
    //            //消息持久化
    //            //var properties = channel.CreateBasicProperties();
    //            //properties.Persistent = true;
    //            byte[] body = Encoding.UTF8.GetBytes("dfdf");
    //            channel.BasicPublish("", "haha", null, body);
    //            return "发送成功   " + input;
    //        }
    //        catch (Exception ex)
    //        {
    //            return "打开失败   " + ex.Message;
    //        }


    //    }
    //}
}
